package nz.ac.massey.se.Q6;

import java.util.ArrayList;
import java.util.List;

public class Course {


    /**
     * Testing Q6.B
     *
     * @author Charles Zheng
     * @id 19029962
     */
    private List<Student> students;

    public Course(String name, int id) {
        students = new ArrayList<>();
    }

    /**
     * get a student based on a given ID
     *
     * @param id
     * @return
     */
    public Student getStudent(Integer id) {
        for (Student student : students) {
            if (student.getId().equals(id)) {
                return student;
            }
        }
        return null;
    }

    /**
     * get the total number of students enrolled in a course
     *
     * @return
     */
    public int getTotalStudents() {
        return students.size();
    }

    /**
     * add a new student to this course
     *
     * @param student
     */
    public void addStudent(Student student) {
        //should check if students already exists. but no time now.
        students.add(student);

    }


    /**
     * remove all students enrolled in this course
     * * @param null
     */
    public void clearEnrolment() {
        students.clear();
    }
}
